***************************************
**** Table 4:	ATTENTIVENESS 		****
***************************************


use "$dir/Data/analysis_main.dta", clear

	
************* TABLE: ATTENTIVENESS ATE

	eststo clear

	* Attentiveness index
	eststo: reghdfe att_ind cash_postpay cash_announce blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	qui estadd local fe1 "Round-wave"		
	test cash_postpay = cash_announce
	qui estadd scalar pval1=r(p)
	
	* High attentiveness
	eststo: reghdfe hiatt_ind cash_postpay cash_announce blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	qui estadd local fe1 "Round-wave"		
	test cash_postpay = cash_announce
	qui estadd scalar pval1=r(p)	
	
	* Heterogeneity: att index, wealth index
	cap drop *_hiw
	foreach x of varlist cash_postpay cash_announce{
		gen `x'_hiw = `x'*wealth_ind_avg
	}		
	eststo: reghdfe att_ind cash_postpay cash_announce cash_postpay_hiw cash_announce_hiw wealth_ind_avg blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	qui estadd local fe1 "Round-wave"
	qui estadd local index "Continuous"	
	lincom cash_postpay - cash_announce
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)			
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	qui lincom cash_postpay + cash_postpay_hiw
	qui estadd scalar coef2 = r(estimate)
	qui estadd scalar se2 = r(se)			
	qui estadd scalar pval2 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	
	* Heterogeneity: att index, high wealth
	cap drop *_hiw
	foreach x of varlist cash_postpay cash_announce{
		gen `x'_hiw = `x'*wealth_hi_avg
	}			
	eststo: reghdfe att_ind cash_postpay cash_announce cash_postpay_hiw cash_announce_hiw wealth_hi_avg blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	qui estadd local fe1 "Round-wave"
	qui estadd local index "Binary"	
	lincom cash_postpay - cash_announce
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)			
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	qui lincom cash_postpay + cash_postpay_hiw
	qui estadd scalar coef2 = r(estimate)
	qui estadd scalar se2 = r(se)			
	qui estadd scalar pval2 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	
	* Heterogeneit: high att, high wealth
	eststo: reghdfe hiatt_ind cash_postpay cash_announce cash_postpay_hiw cash_announce_hiw wealth_hi_avg blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	qui estadd local fe1 "Round-wave"
	qui estadd local index "Binary"	
	lincom cash_postpay - cash_announce
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)			
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	qui lincom cash_postpay + cash_postpay_hiw
	qui estadd scalar coef2 = r(estimate)
	qui estadd scalar se2 = r(se)			
	qui estadd scalar pval2 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	

	
label var cash_postpay "Cash $\times$ Post-pay" 	
label var cash_announce "Cash $\times$ Announcement period" 	
label var cash_postpay_hiw "Cash $\times$ Post-pay $\times$ Higher wealth" 
label var cash_announce_hiw "Cash $\times$ Announcement $\times$ Higher wealth" 
	
#delimit ;
local tablerow cash_postpay cash_postpay_hiw cash_announce cash_announce_hiw;

esttab using "$om/$t/Table_4.tex", 
    b(3) se booktabs star(* .1 ** .05 *** .01) collabels(,none) nonotes nomtitles 
    replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
    stats(pval1 index coef2 se2 pval2 N, labels("P-val: Cash $\times$ Post-pay = Cash $\times$ Announcement" "Wealth index" "Coef: Cash $\times$ Post-pay + Cash $\times$ Post-pay $\times$ Wealth" "SE: Cash $\times$ Post-pay + Cash $\times$ Post-pay $\times$ Wealth" "P-val: Cash $\times$ Post-pay + Cash $\times$ Post-pay $\times$ Wealth" "N: worker-hours") fmt(%9.3fc %50s %9.3fc %9.3fc %9.3fc %9.0fc))    
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
	\begin{tabular}     
	{@{\extracolsep{4pt}}l*{15}{>{\centering\arraybackslash}m{2.8cm}}@{}}      \toprule    
	&Attentiveness index  &High attentiveness   &Attentiveness index &Attentiveness index  &High attentiveness  \bigstrut  \\     
	") ;
		
#delimit cr	

